package com.cnswhy.cloud.server.app.utils;

import java.io.*;
import java.util.Properties;

/**
 * @author HuangHL
 * @date 2015/12/10
 * @see
 */
public class ConfigProperties
{
    
    public static Properties prop = new Properties();
    
    static
    {
        // String configPath = FileUtil.getClassPathFilePath() + "config/";
        String configPath = FileUtil.getClassPathFilePath();
        File path = new File(configPath);
        if (!path.exists())
        {
            // configPath = FileUtil.getClassPathFilePath().replaceAll("/lib", "") + "config/";
            configPath = FileUtil.getClassPathFilePath().replaceAll("/lib", "");
            path = new File(configPath);
        }
        if (!path.exists())
        {
            // if (configPath.indexOf("/common/target/classes/config") != -1)
            if (configPath.indexOf("/common/target/classes") != -1)
            {
                configPath = configPath.replaceAll("/classes", "");
                path = new File(configPath);
            }
        }
        
        // system web 写死， 只获取system_config.properties配置文件 add by jsw 2018-06-07
        InputStream inStream = null;
        try
        {
            inStream = new FileInputStream(new File(configPath + "system_config.properties"));
            try
            {
                prop.load(inStream);
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
        }
        catch (FileNotFoundException e)
        {
            e.printStackTrace();
        }
    }
    
    public static String getStringValue(String key)
    {
        return prop.getProperty(key);
    }
    
}
